package com.tianshi.product.mapper;

import com.tianshi.entity.Categories;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface CategoryMapper {


    @Select("SELECT * FROM categories WHERE category_id = #{categoryId}")
    Categories getCategoryById(@Param("categoryId") Long categoryId);


    @Select("SELECT * FROM categories")
    List<Categories> getAllCategory();

    @Insert("INSERT INTO categories(category_name, parent_id,sort_order) VALUES( #{categoryName}, #{parentId}, #{sortOrder})")
//    @Options(useGeneratedKeys = true, keyProperty = "id")
    Long addCategory(Categories categories);

    @Update("UPDATE categories SET category_name = #{categoryName}, parent_id = #{parentId}, sort_order = #{sortOrder} WHERE category_id = #{categoryId}")
    Long updateCategory(Categories category);

    @Delete("DELETE FROM categories WHERE category_id = #{categoryId}")
    Long deleteCategory(@Param("categoryId") Long categoryId);
}
